#if (FEATURE_MODE == 0)
/**
 @file ctc_tmx_diag.h

 @author  Copyright (C) 2019 Centec Networks Inc.  All rights reserved.

 @date 2019-04-01

 @version v5.0

 This module provides various functions to diagnosis chip.

 \b
 \p
 Diag moulde supports packet trace, drop reporting, table operation, load balance distribution, memory usage and other functions. Some functions
 can be applied to visualization solutions.
 \p

 \b
 \p
 Packet trace can see the details of the packet which from network port or CPU port forwarded in the chip. It needs to be triggered first, based
 on watch key, which is the key field parsed from the packet. And it can set the watch point to get the information we want. The watch point
 can be IPE, BSR or EPE. It gets the forwarding table information through the API ("ctc_diag_get_pkt_trace/ctcs_diag_get_pkt_trace"), they are
 all strings, which is convenient for visualization.
 \p

 \b
 \p
 Drop reporting can report packet information which droped by the chip in real time. The information includes the body of the drop packet, the drop
 reasons, and the network port. It can generate a packet ID for each reporting packet. The packet ID can be used in packet trace.
 \p

 \b
 \p
 Table operation can support reading and writing physical tables, and can fuzzy match table names according to specified strings.
 \p

 \b
 \p
 Load balance distribution can obtain the traffic load of LINKAGG or ECMP members in real time.
 \p

 \b
 \p
 Memory usage can get the current chip resource usage in real time, these resources include sram and tcam.
 \p

 \b
 \p
 Lb Hash can get the packet which forward to linkagg or ecmp, hash val and output member port or nexthop id:
 \p
 \d The diag lb hash only support match eth,ipv4 and ipv6. VXLAN and Gre packet only support outer info and vni,grekey.
    Depending on the Packet Type, can match different fields:
 \p
 \t   |    Packet          |   Fields                                                               |
 \t   |--------------------|------------------------------------------------------------------------|
 \t   |    IPv4            | L3Type(Must),L4Type, L4UserType, IPDA, IPSA, L4_DST_PORT, L4_SRC_PORT,IP_PROTOCOL,IP_FRAG,VNI,GREKEY |
 \t   |    Ipv6            | L3Type(Must),L4Type, L4UserType, IPV6DA, IPV6SA, L4_DST_PORT, L4_SRC_PORT,IP_PROTOCOL,IP_FRAG,FLOWLABL,VNI,GREKEY |
 \t   |    ETH             | MACSA, MACDA, SVLAN, CVLAN, ETHERTYPE                                  |
 \t   |--------------------|------------------------------------------------------------------------|
 \p
 \b
*/

#ifndef _CTC_USW_DIAG_H
#define _CTC_USW_DIAG_H
#ifdef __cplusplus
extern "C" {
#endif

#include "sal.h"
#include "ctc_diag.h"

/**********************************************************************************
                      Define API function interfaces
***********************************************************************************/
/**
 @addtogroup diag DIAG
 @{
*/

/**
 @brief Init diag module

 @param[in] lchip    local chip id

 @param[in]  init_cfg  diag global config information

 @remark[TM.TMM] Initialize the module diag, including global variable, soft table, asic table, etc.

 @return CTC_E_XXX

*/
extern int32
ctc_tmx_diag_init(uint8 lchip, void* init_cfg);

/**
 @brief De-Initialize chip module

 @param[in] lchip    local chip id

 @remark[TM.TMM]  User can de-initialize the diag configuration

 @return CTC_E_XXX
*/
extern int32
ctc_tmx_diag_deinit(uint8 lchip);

/**
 @brief The function is to trigger packet trace

 @param[in] lchip_id    local chip id

 @param[in|out] p_trace  trace confition

 @remark[TM.TMM]   To trigger packet trace with the given watch point and watch key.

 @return CTC_E_XXX
*/
extern int32
ctc_tmx_diag_trigger_pkt_trace(uint8 lchip_id, ctc_diag_pkt_trace_t* p_trace);

/**
 @brief The function is to get packet trace result info

 @param[in] lchip_id    local chip id

 @param[in|out] p_rslt  trace reault info

 @remark[TM.TMM]   To get packet trace result info with the given watch point.

 @return CTC_E_XXX
*/
extern int32
ctc_tmx_diag_get_pkt_trace(uint8 lchip_id, ctc_diag_pkt_trace_result_t* p_rslt);

/**
 @brief The function is to get chip droped info

 @param[in] lchip_id    local chip id

 @param[in|out] p_drop  drop info

 @remark[TM.TMM]   To get chip droped info through the given conditions.
  \p
  \d 1. Get which ports have droped packets through CTC_DIAG_DROP_OPER_TYPE_GET_PORT_BMP.
  \d 2. Get the drop reasons on a specific port through CTC_DIAG_DROP_OPER_TYPE_GET_REASON_BMP.
  \d 3. Get drop detail info for the specific port and the specific drop reason through CTC_DIAG_DROP_OPER_TYPE_GET_DETAIL_INFO.
  \p

  \p
     For CTC_DROP_TRAFFIC_MANAGER/CTC_DROP_NET_TX/CTC_DROP_NET_RX/CTC_DROP_OAM, the drop statistics are inaccurate
     and only used to oberve the changes.
  \p
 @return CTC_E_XXX
*/
extern int32
ctc_tmx_diag_get_drop_info(uint8 lchip_id, ctc_diag_drop_t* p_drop);

/**
 @brief The function is to set diag module property

 @param[in] lchip_id    local chip id

 @param[in] prop    diag property

 @param[in] p_value        diag property value

 @remark[TM.TMM]  This API provides a ability to control the various features.

 @return CTC_E_XXX

*/
extern int32
ctc_tmx_diag_set_property(uint8 lchip_id, ctc_diag_property_t prop, void* p_value);

/**
 @brief The function is to get diag module property

 @param[in] lchip_id    local chip id

 @param[in] prop    diag property

 @param[in] p_value        diag property value

 @remark[TM.TMM]  This API provides a ability to obtain the various features' value.

 @return CTC_E_XXX

*/
extern int32
ctc_tmx_diag_get_property(uint8 lchip_id, ctc_diag_property_t prop, void* p_value);

/**
 @brief The function is to operate table

 @param[in] lchip_id   local chip id

 @param[in|out] p_para        diag table info

 @remark[TM.TMM]  This API provides a ability to operate the table.

 @return CTC_E_XXX

*/
extern int32
ctc_tmx_diag_tbl_control(uint8 lchip_id, ctc_diag_tbl_t* p_para);

/**
 @brief The function is to config load balancing distribution

 @param[in] lchip_id    local chip id

 @param[in] p_para        diag load balancing distribution configuration

 @remark[TM.TMM]  This API provides a ability to config load balancing distribution.

 @return CTC_E_XXX

*/
extern int32
ctc_tmx_diag_set_lb_distribution(uint8 lchip_id,ctc_diag_lb_dist_t* p_para);
/**
 @brief The function is to get load balancing distribution info

 @param[in] lchip_id    local chip id

 @param[in|out] p_para        diag load balancing distribution info

 @remark[TM.TMM]  This API provides a ability to get load balancing distribution info.

 @return CTC_E_XXX

*/
extern int32
ctc_tmx_diag_get_lb_distribution(uint8 lchip_id,ctc_diag_lb_dist_t* p_para);
/**
 @brief The function is to get memory usage status

 @param[in] lchip_id    local chip id

 @param[in|out] p_para        diag memory usage status

 @remark[TM.TMM]  This API provides a ability to get memory usage status.

 @return CTC_E_XXX

*/
extern int32
ctc_tmx_diag_get_memory_usage(uint8 lchip_id,ctc_diag_mem_usage_t* p_para);

/**
 @brief The function is to check hardward memory of chip is good or not

 @param[in] lchip_id    local chip id

 @param[in] mem_type  memory bist type

 @param[in|out] p_err_mem_id  memory bist error mem-id

 @remark[TM.TMM]  This API provides a ability to enable chip-bist to to check hardward memory of chip is good or not.

 @return CTC_E_XXX

*/
extern int32
ctc_tmx_diag_mem_bist(uint8 lchip_id, ctc_diag_bist_mem_type_t mem_type, uint8* p_err_mem_id);

/**
 @brief The function is to get the queue depth when the queue becomes congested

 @param[in] lchip_id    local chip id

 @param[in|out] p_queue  the congested queue info

 @remark[TM.TMM]  This API provides a ability to get the congested queue-id and queue-depth.

 @return CTC_E_XXX

*/
extern int32
ctc_tmx_diag_get_queue_depth(uint8 lchip_id, ctc_diag_queue_depth_t* p_queue);

/**
 @brief The function is to get the lb hash with packet info

 @param[in] lchip_id    local chip id

 @param[in] p_field_list     Pointer to key field list.

 @param[in] field_cnt     Field number of key.

 @param[in|out] p_rslt    some other packet info

 @remark[TM.TMM]  This API provides a ability to get the hash result for the specified 
                  linkagg group or ecmp group with using provided packet parameters.

 @return CTC_E_XXX

*/
extern int32
ctc_tmx_diag_get_lb_hash(uint8 lchip_id, ctc_field_key_t* p_field_list, uint32 field_cnt, ctc_diag_lb_hash_t* p_rslt);
/**@} end of @addtogroup diag DIAG*/

#ifdef __cplusplus
}
#endif

#endif  /*_CTC_USW_DIAG_H*/
#endif

